<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<%@include file="../include/header.jsp" %>
<c:if test="${sessionScope.userid == null }">
	<script type="text/javascript">
		alert("로그인이 필요한 서비스입니다");
		location.href="${path}/member/login.jsp";
	</script>
</c:if>
<script type="text/javascript">
function class_delete(){
	if(confirm("삭제하시겠습니까?")){
		location.href='${path}/class1/class1_delete.do?idx=${map.dto.idx}';
	}
}
function class_resist(){
	
	if(confirm("신청하시겠습니까?")){
		location.href='${path}/class1/class1_resist.do?idx=${map.dto.idx}';
	}
}

function openWin(){
	var url="${path}/images/pop/map.jpg";
	window.open(url,"","left=200,top=100,width=452,height=300");
}

function admin_price(){
	var form_admin_price = document.getElementById("form_admin_price");
	var price = document.getElementById("price");
	if( price.value == "" ) {
		alert("가격을 입력하세요");
		price.focus();
		return;
	}
	if(confirm("입력한 가격이 "+price.value+"원 이 맞습니까? 한번 설정하면 취소할 수 없습니다.")){
	form_admin_price.action="${path}/class1/class1_admin_update.do";
	form_admin_price.submit();
	}
}

</script>
</head>
<body>
<h2>class_detail</h2>
<table border="1" style="width:898px; margin:0 auto;">
 <tr>
  <td colspan="2" align="left">Subject&nbsp;&nbsp;|&nbsp;&nbsp;<b>${map.dto.subject}</b></td> 
  <td colspan="2" align="right">
  <!-- 본인작성확인 -->
  <c:if test="${sessionScope.userid==map.dto.userid || sessionScope.userid=='admin'}"><a href="#" onclick="location.href='${path}/class1/class1_edit.do?idx=${map.dto.idx}';">
  EDIT</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="#" onclick="class_delete();">DELETE</a></c:if></td>
 </tr>
 <tr>
  <td colspan="2" align="left">${map.dto.c_name}&nbsp;&nbsp;|&nbsp;&nbsp;조회수&nbsp;:&nbsp;${map.dto.hit}
  <td colspan="2" align="right">작성일&nbsp;:&nbsp;${map.dto.post_date}</td>
 </tr>
 <tr>
  <td colspan="4" align="left">강좌일&nbsp;&nbsp;:&nbsp;&nbsp;${map.dto.class_date}</td>
 </tr>
 <tr>
  <td colspan="4" align="left">장소&nbsp;&nbsp;:&nbsp;&nbsp;<a href="#" onclick="openWin()">쌍용교육센터</a> 지하 1층 요리실습장</td>
 </tr>
 <tr>
  <td colspan="4" align="center"><br><br><br>${map.dto.content}<br><br><br>
  <c:if test="${sessionScope.userid!=null}">
<c:choose>
 <c:when test="${map.dto.cnt==10}"><font color=red>본 강좌는 마감되었습니다</font></c:when>
 <c:when test="${map.dto.cnt<10}">
   <c:if test="${sessionScope.userid != map.dto.userid}">
   <input type="button" id="btnJoinClass" name="btnJoinClass" value="신청할래요:)" onclick="class_resist();">
   </c:if>
 </c:when>
</c:choose>
</c:if>
  <br><br><br></td>
 </tr>
 <tr>
  <td colspan="4" align="left">▶강좌 예정 레시피</td>
 <tr height="134px">
  <td align="center" width="179px"><img alt="class1" width="177px" height="124px" src="${path}/images/images/kimbok.jpg"></td>
  <td width="240px">#${map.dto.recipe_idx1}.<a href="${path }/recipe/recipe_detail.do?idx=${map.dto.recipe_idx1}">${map.dto.recipe_name1}</a></td>
  <c:if test="${map.dto.recipe_idx2!=0}">
  <td align="center" width="179px"><img alt="class2" width="177px" height="124px" src="${path}/images/images/yubu.jpg"></td>
  <td width="240px">#${map.dto.recipe_idx2}.<a href="${path }/recipe/recipe_detail.do?idx=${map.dto.recipe_idx2}">${map.dto.recipe_name2}</a></td>
  </c:if>
 </tr>
 <tr>
  <td colspan="4" align="center"><input type="button" value="목록" onclick="location.href='${path}/class1/class1_list.do';">
  </table>
  <c:if test="${sessionScope.level=='0' && map.dto.state=='0'}">
  
  <div id="div_admin_class">
  <hr>
   <h4>▶▶▶관리자용</h4>
   <form name="form_admin_price" id="form_admin_price" method="post">
    강좌비를 설정해주세요(단위: 원)<br>
     <input type="hidden" name="idx" value="${map.dto.idx}">
     <input type="text" name="price" id="price" size="30">
     <input type="button" value="가격확정" onclick="admin_price()">
   </form>
  </div>
  </c:if>
</body>
</html>